<!doctype html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <title>首页</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.4.1/dist/css/bootstrap.min.css">
    <link rel="stylesheet" href="/css/style.css">
</head>

<body class="bg-light">
    <nav class="navbar navbar-expand-lg navbar-dark bg-dark">
        <a class="navbar-brand" href="#">
            <img src="/img/logo.png" width="30" height="30" alt="">
        </a>
        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent">
            <span class="navbar-toggler-icon"></span>
        </button>

        <div class="collapse navbar-collapse" id="navbarSupportedContent">
            <ul class="navbar-nav">
                <% category.forEach(category=> { %>
                <li class="nav-item">
                    <a class="nav-link" href="/article/list/<%= category.id %>"><%= category.name %></a>
                </li>
               <% });%>
            </ul>
            <form class="form-inline my-2 my-lg-0 ml-5" method="get" action='/search'>
                <input class="form-control mr-sm-2" name="keyword" type="search" placeholder="请输入关键词...">
                <button class="btn btn-outline-success my-2 my-sm-0" type="submit">搜索</button>
            </form>
            <ul class="navbar-nav ml-auto">
                <% if(user){ %>
                    <li class="nav-item dropdown">
                        <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" data-toggle="dropdown">
                            <%= user.username %>
                        </a>
                        <div class="dropdown-menu">
                            <a class="dropdown-item" href="/user/logout">退出</a>
                        </div>
                    </li>
                <% } else{%>
                <li class="nav-item">
                    <a href="/login" class="nav-link">登录</a>
                </li>
                <% };%>
            </ul>
        </div>
    </nav>